/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.matheval.function;

/**
 *
 * @author Luca
 */
public class Uniform extends FunctionDefinition {

    public Uniform() {
        super.name = "uniform";
        super.arity = -1;
        super.minimumArity = 0;
        super.maximumArity = 2;
        super.type = FunctionType.STATIC_ARBITRARY;
        super.randomFunction = true;
    }

    @Override
    public double compute() {
        return RandomGenerator.nextUniform();
    }

    @Override
    public double compute(double x) {
        return x * RandomGenerator.nextUniform();
    }



    @Override
    public double compute(double x1, double x2) {
        return x1 + RandomGenerator.nextUniform() * (x2-x1);
    }
}